<?php
/**
 * Created by PhpStorm.
 * User: huynguyen
 * Date: 9/24/14
 * Time: 11:04 PM
 */

namespace Common\library;

class Common
{
    public static function listYear()
    {
        $year = array();
        for($i = 2014;$i >= 1905; $i--)
        {
            $year[$i] = $i;
        }
        return $year;
    }

    public static function listStatus()
    {
        return array(
            'A' => 'Hoạt động' ,
            'H' => 'Ẩn' ,
            'D' => 'Vô hiệu hóa',
            'W' => 'Đang chờ',
        );
    }

    public static function listSourceFile()
    {
        return array(
            'J' => 'JAVHD Server',
            'Y' => 'Youtube',
            'V' => 'Vimeo',
            'D' => 'Dailymotion'
        );
    }

    public static function listAgentVideo()
    {
        return array(
            'C' => 'Computer',
            'A' => 'Android',
            'I' => 'IOS',
            'W' => 'Windown Phone',
            'F' => 'Tất cả'
        );
    }

    public static function listProtocol()
    {
        return array(
            'http' => 'http',
            'https' => 'https',
        );
    }

    public static function listQuanlity()
    {
        return array(
            '360' => 360,
            '720' => 720,
            '1080' => 1080
        );
    }

    public static function listThumbnailOptionA()
    {
        return array(
            '130_130' => array(
                'width' => 130,
                'height' => 130,
            ),
            '160_230' => array(
                'width' => 160,
                'height' => 230,
            ),
            '220_124' => array(
                'width' => 220,
                'heigh' => 124
            ),
            '476_268' => array(
                'width' => 476,
                'heigh' => 268
            )
        );
    }

    public static function listThumbnailOptionB()
    {
        return array(
            '300_150' => array(
                'width' => 130,
                'height' => 130,

            ),
            '300_250' => array(
                'width' => 160,
                'height' => 230
            ),
        );
    }

    public static function listGroupType()
    {
        return array(
            'U' => "User",
            'A' => "Administrators"
        );
    }

    public static function stripTag($str){
        $str = preg_replace("/(à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ)/", 'a', $str);
        $str = preg_replace("/(è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ)/", 'e', $str);
        $str = preg_replace("/(ì|í|ị|ỉ|ĩ)/", 'i', $str);
        $str = preg_replace("/(ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ)/", 'o', $str);
        $str = preg_replace("/(ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ)/", 'u', $str);
        $str = preg_replace("/(ỳ|ý|ỵ|ỷ|ỹ)/", 'y', $str);
        $str = preg_replace("/(đ)/", 'd', $str);
        $str = preg_replace("/(À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ)/", 'A', $str);
        $str = preg_replace("/(È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ)/", 'E', $str);
        $str = preg_replace("/(Ì|Í|Ị|Ỉ|Ĩ)/", 'I', $str);
        $str = preg_replace("/(Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ớ|Ợ|Ở|Ỡ)/", 'O', $str);
        $str = preg_replace("/(Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ)/", 'U', $str);
        $str = preg_replace("/(Ỳ|Ý|Ỵ|Ỷ|Ỹ)/", 'Y', $str);
        $str = preg_replace("/(Đ)/", 'D', $str);
        $str = trim(strtolower(preg_replace('/[^ a-z0-9]+/i', '-', $str)));
        $str = str_replace('-','',$str) ;
        $str = trim(strtolower(preg_replace('/[^a-z0-9]+/i', '-', $str)));
        return $str;
    }
} 